// 引入axios实例
import { request } from '@/utils/http'
import { Key } from 'react'
import {
  IhospitalListParams,
  IhospitalListResponse,
  IprovinceList,
  IhospitalDetailResponse,
  IdepList,
} from '@api/hospital/model/hospitalListTypes'

// 定义获取医院设置表格数据的函数
export function reqHospitalList(params: IhospitalListParams) {
  const {
    page,
    limit,
    hosname,
    hoscode,
    hostype,
    provinceCode,
    cityCode,
    districtCode,
    status,
  } = params
  // 这里传入IhospitalSetResponse, 是描述响应回来的数据类型
  return request.get<any, IhospitalListResponse>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: {
        hosname,
        hoscode,
        hostype,
        provinceCode,
        cityCode,
        districtCode,
        status,
      },
    }
  )
}

// 定义获取省数据的函数
export function reqGetProvince(dictCode = 'province') {
  return request.get<any, IprovinceList>(
    `/admin/cmn/dict/findByDictCode/${dictCode}`
  )
}

// 定义获取市或区数据或医院等级数据的函数
// parentId如果是省数据的value,则返回市的数据
// parentId如果是市数据的value,则返回区的数据
//parentId如果是1000,则返回医院等级的数据

export function reqCityOrDistrict(parentId: string) {
  return request.get<any, IprovinceList>(
    `/admin/cmn/dict/findByParentId/${parentId}`
  )
}

// 定义获取医院详情的函数
export function reqHospitalDetail(id: string) {
  return request.get<any, IhospitalDetailResponse>(
    `/admin/hosp/hospital/show/${id}`
  )
}

// 定义获取排班界面-所有科室数据的函数
export function reqHospitalScheduleDep(hoscode: string) {
  return request.get<any, IdepList>(`/admin/hosp/department/${hoscode}`)
}
